package cn.itcast.bos.web.action.take_delivery;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.take_delivery.Order;
import cn.itcast.bos.service.take_delivery.OrderService;
import cn.itcast.bos.web.action.common.BaseAction;

public class OrderAction extends BaseAction<Order>{
	@Resource
	private OrderService service;
	@Action(value="order_findByOrderNum",results={@Result(name="success",type="json")})
	public String findByOrderNum(){
		//封装回显数据
		Map<String, Object> results = new HashMap<>();
		Order order = service.findByOrderNum(model.getOrderNum());
		if (order == null) {
			results.put("success", false);
			results.put("msg", "订单号不存在!");
		}else{
			if (order.getWayBill() != null) {
				results.put("success", false);
				results.put("msg", "订单已经关联运单!");
			}else{
				results.put("success", true);
				results.put("orderData", order);
			}
		}
		ActionContext.getContext().getValueStack().push(results);
		return SUCCESS;
	}
	
	
}
